<template>
  <div class="table">
    <el-table
      :data="tableData"
      :loading="loading"
      @selection-change="handleSelectionChange"
      style="width: 100%"
      :header-cell-style="{
        background: '#F1F1F1',
        'font-size': '14px',
        'font-weight': 600,
        color: '#333333',
      }"
      :cell-style="{
        'font-size': '14px',
        'font-weight': 400,
        color: '#333333',
      }"
    >
      <el-table-column type="selection" width="55" fixed="left" />
      <el-table-column label="序号" min-width="60" fixed="left">
        <template #default="scope">
          {{ (scope.$index + 1).toString().padStart(2, "0") }}
        </template>
      </el-table-column>
      <el-table-column prop="operatorName" label="运营商" />
      <el-table-column prop="iccid" label="编码" min-width="200" />
      <el-table-column prop="expiresIn" label="到期时间" min-width="110" />
      <el-table-column prop="flux" label="流量包(G)" min-width="90" />
      <el-table-column prop="statusName" label="使用状态" />
      <!-- <el-table-column prop="status" label="使用状态">
        <template #default="scope">
          {{ scope.row.status === true ? "使用中" : "已报废" }}
        </template>
      </el-table-column> -->
      <el-table-column label="操作" width="110" fixed="right">
        <template #default="scope">
          <el-button
            @click="editData(scope.row)"
            type="primary"
            size="small"
            link
            style="color: #007aff; font-size: 14px"
            >编辑</el-button
          >
          <!-- <el-button
            @click="journal(scope.row)"
            type="primary"
            size="small"
            link
            style="color: #007aff"
            >日志</el-button
          > -->
          <el-button
            @click="deleteData(scope.row)"
            type="primary"
            size="small"
            link
            style="color: #007aff; font-size: 14px"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
import { reactive, ref, defineProps } from "vue";
const imgNone = new URL("@/assets/image/imgNone.png", import.meta.url).href;
const emits = defineEmits(["table"]);

const props = defineProps({
  tableData: {
    type: Object,
    default: () => {},
  },
  loading: {
    type: Boolean,
    default: false,
  },
});

const bingSIMIdList = ref([]);

const handleSelectionChange = (val) => {
  let row = {};
  row.operation = 3;
  bingSIMIdList.value = val.map((proxy) => proxy.simId);
  row.bingSIMIdList = bingSIMIdList.value;
  emits("table", row);
};

// 编辑按钮
const editData = (row) => {
  row.operation = 1;
  emits("table", row);
};

// 删除按钮
const deleteData = (row) => {
  row.operation = 2;
  emits("table", row);
};
</script>

<style lang="less" scoped>
.table {
  margin-bottom: 15px;
}
</style>